package sqlOperate;
/**
 * 驱动数据库
 */
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class JdbcDriver {
	private String driverName;
	private String url;
	private String username;
	private String password;
	private Connection conn = null;

	public void Driver() {
		driverName = "com.mysql.jdbc.Driver";
		url = "jdbc:mysql://39.108.12.42:3306/test";
		username = "root";
		password = "123456";
		
		try {
			
			Class.forName(driverName);
			
			System.out.println("加载成功");
			
			conn = DriverManager.getConnection(url, username, password);
			
		} catch (SQLException e1) {
			e1.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	public Connection getConn() {
		return conn;
	}
}
